home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d8 / ragtag_3.arc / RAGTAG.SLT < prev    next >
Text File  |  1990-04-12  |  6KB  |  127 lines

  1. // RagTag, version 0.03
  2. //
  3. // Telix script for adding taglines to messages written online,
  4. // using the John Hancock (JH) program, version 2.  
  5. //
  6. // Written by Maurice Crouse, 29 March 1990.
  7. // Revision 0.02 written 2 April 1990.
  8. // Revision 0.03 written 12 April 1990.
  9. //
  10. // See RAGTAG.DOC file for documentation on how to use this script.
  11.  
  12. str tag [50] = "",                   //holds tagline from JH;
  13.     logo [] = " * RagTag 0.03 *  ",  //holds RagTag logo;
  14.     tear_line [] = "---",            //holds the "tear line";
  15.     enter [] = "^M",                 //equate for Carriage Return;
  16.     space [] = " ",                  //equate for Space character;
  17.     jh_dir [64] = "",                //JH directory;
  18.     tlx_dir [64] = "",               //Telix directory;
  19.     change_tlx [68] = "cd ",         //holds first change string;
  20.     change_jh [68] = "cd ";          //holds second change string;
  21.  
  22. main ()
  23.  {
  24.   int stat = 0;                      //local variable;
  25.   stat = read_cnf ();       //try to read configuration file;
  26.   if (stat == -1 )          //if error in opening file or setting
  27.    {                                 //JH variable, try to find JH in
  28.     if (filefind ("jh.exe",0) == 0)  //current directory;
  29.      {                               //if unsuccessful,
  30.       status_wind ("Can't find JH.  Sorry, no tagline.");
  31.       return;                        //quit with apology;
  32.      }
  33.    }
  34.   if (stat == -2)
  35.     status_wind ("Won't be able to get back to Telix directory.",15);
  36.   status_wind ("Calling JH to get tagline.",15);
  37.   if (get_tag () == -1)                      //try to get tag; if error,
  38.     status_wind ("Sorry, can't add the tagline.",15); //admit it;
  39.   else                                       //otherwise,
  40.    {
  41.     cputs (space);                     //enter a blank line,
  42.     cputs (enter);
  43.     cputs (tear_line);                 //send the "tear line,"
  44.     cputs (enter);
  45.     cputs (logo);                      //send the logo,
  46.     cputs (tag);
  47.     cputs (enter);                     //and send the tagline;
  48.    }
  49.  }
  50.  
  51. read_cnf ()
  52.  {
  53.   int f = 0,                           //local variables;
  54.       stat = 0;
  55.   f = fopen ("ragtag.cnf","r");        //open RAGTAG.CNF for reading;
  56.   if (not f)                           //if an error in reading it,
  57.    {
  58.     status_wind ("Can't open configuration file.",15);
  59.     status_wind ("Will try to find JH in current directory.",15);
  60.     fclose (f);                        //close RAGTAG.CNF;
  61.     return -1;                         //return error -1;
  62.    }
  63.   stat = fgets (jh_dir, 64, f);        //set JH directory variable;
  64.   if (stat == -1)                      //if unsuccessful,
  65.    {
  66.     status_wind ("Can't find JH directory information.",15);
  67.     status_wind ("Will try to find JH in current directory.",15);
  68.     fclose (f);                        //close RAGTAG.CNF;
  69.     return -1;                         //return error -1;
  70.    }
  71.   stat = fgets (tlx_dir, 64, f);       //set Telix directory variable;
  72.   if (stat == -1)                      //if unsuccessful,
  73.    {
  74.     status_wind ("Can't find Telix directory information.",15);
  75.     fclose (f);                        //close RAGTAG.CNF;
  76.     return -2;                         //return error -2;
  77.    }
  78.   fclose (f);                          //close RAGTAG.CNF;
  79.  }
  80.  
  81. get_tag ()
  82.  {
  83.   int f = 0,                           //local variables;
  84.       dir_changed = 0,
  85.       stat = 0;
  86.   if (not (jh_dir == ""))              //if the JH directory is defined
  87.    {                                   //in RAGTAG.CNF,
  88.     strcat (change_jh, jh_dir);
  89.     dos (change_jh);                   //change directory;
  90.     dir_changed = 1;                   //set "changed" flag;
  91.    }
  92.  dos ("if exist jh?.rep del jh?.rep"); //erase any old .REP file;
  93.  if (run ("jh","",0) == -1)            //run the JH program;
  94.    {                                   //if an error in running it,
  95.     status_wind ("Can't run JH.",15);  //admit it;
  96.     goto got_error;
  97.    }                           //rename the .REP file created by 
  98.   dos ("if exist jh?.rep ren jh?.rep jhx.rep"); //JH2 to JHX.REP; 
  99.   f = fopen ("jhx.rep","r");           //open JHX.REP for reading;
  100.   if (not f)                           //if an error in reading it,
  101.    {                                   //admit it;
  102.     status_wind ("Can't find the tagline file.",15);
  103.     goto got_error;
  104.    }
  105.   stat = fgets (tag, 80, f);           //copy JHX.REP into tag array;
  106.   if (stat == -1)                      //if unsuccessful,
  107.    {                                   //admit it;
  108.     status_wind ("Can't get a copy of the tagline.",15);
  109.     goto got_error;
  110.    }                                   //if we get this far, no errors;
  111.   fclose (f);                          //close JHX.REP;
  112.   if (dir_changed == 1)
  113.    {                                   //if directory was changed
  114.     strcat (change_tlx,tlx_dir);       //earlier,
  115.     dos (change_tlx);                  //change directory back to Telix;
  116.    }
  117.   return 1;                            //return success code;
  118.   got_error:                           //if we end here, error was made;
  119.   fclose (f);                          //close JHX.REP;
  120.   if (dir_changed == 1)
  121.    {                                   //if directory was changed
  122.     strcat (change_tlx,tlx_dir);       //earlier,
  123.     dos (change_tlx);                  //change directory back to Telix;
  124.    }
  125.   return -1;                           //return error code;
  126.  }                                     //END OF SCRIPT
  127.